import request from '../../request'
import { AxiosResponse } from 'axios'
import { LoginFrom } from '@/types/views/login'
import { ResponseData } from '@/types/api/public'
import { TableList,EditData,RoleInput } from '@/types/api/syssetting/role'

type ConfigType<T=ResponseData> = Promise<AxiosResponse<T>>

export const getData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    return request({
       url:'/Role/QueryRoles',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getAllRoleListData =():ConfigType<any> =>{
    return request({
       url:'/Role/QueryAllRoles',
       method:'get',
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getRoleInfo =(params:any):ConfigType<any> =>{
    return request({
       url:'/Role/QueryRoleInfo',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const setRole =(data:RoleInput):ConfigType =>{
    return request({
       url:'/Role/SetRole',
       method:'post',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const delRole =(params:any):ConfigType =>{
    return request({
       url:'/Role/DeleteRole',
       method:'get',
       params,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}


export const getMenuTreeData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    const data= JSON.stringify(params);
    return request({
       url:'/Menu/QueryAllMenuTrees',
       method:'get',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}

export const getApiData =(params:any):ConfigType<TableList> =>{
    params.PageIndex=params.current;
    params.PageSize=params.pageSize;
    const data= JSON.stringify(params);
    return request({
       url:'/Api/QueryApis',
       method:'get',
       data,
        headers: {
            'Content-Type': 'application/json-patch+json'
          }
    })
}
